

    \filetitle{rollback}{Prepare database for a rollback run of Kalman filter}{model/rollback}

	\paragraph{Syntax}\label{syntax}

\begin{verbatim}
Inp = rollback(M,Inp,Range,Date)
\end{verbatim}

\paragraph{Input argument}\label{input-argument}

\begin{itemize}
\item
  \texttt{M} {[} model {]} - Model object with a single
  parameterization.
\item
  \texttt{Inp} {[} struct {]} - Database with a single set of input data
  for a Kalman filter.
\item
  \texttt{Range} {[} numeric {]} - Filter data range.
\item
  \texttt{Date} {[} numeric {]} - Date up to which the input data
  entries will be rolled back, see Description.
\end{itemize}

\paragraph{Output argument}\label{output-argument}

\begin{itemize}
\itemsep1pt\parskip0pt\parsep0pt
\item
  \texttt{Inp} {[} struct {]} - New database with new data sets added to
  each tseries for measurement variables, taking out one observation at
  a time, see Description.
\end{itemize}

\paragraph{Description}\label{description}

The function \texttt{rollback} takes a database with a single set of
input data that is supposed to be used in a future call to a Kalman
filter, \href{model/filter}{\texttt{model/filter}}, and creates
additional data sets (i.e.~addition columns in tseries for measurement
variables contained in the database) in the following way:

\begin{itemize}
\item
  the total number of the new data sets (new columns added to each
  measurement tseries) is N = NPer*Ny where NPer is the number of
  rollback periods, from \texttt{Date} to the end of \texttt{Range}
  (including both), and Ny is the number of measurement variables in the
  model \texttt{M}.
\item
  The first additional data set is created by removing the observation
  on the last measurement variable in the last period (i.e.~end of
  \texttt{Range}) and replacing it with a \texttt{NaN}.
\item
  The second additional data set is created by removing the observatoins
  on the last two measurement variables in the last period, and so on.
\item
  The N-th (last) additional data set is created by removing all
  observations in all periods between \texttt{Data} and end of
  \texttt{Range}.
\end{itemize}

\paragraph{Example}\label{example}

If the model \texttt{m} contains, for instance, 3 measurement variable,
the following commands will produce a total of 13 Kalman filter runs,
the first one on the original database d, and the other 12 on the
rollback data sets, with individual observations removed one by one:

\begin{verbatim}
dd = rollback(m,d,qq(2000,1):qq(2015,4),qq(2015,1));
[mf,f] = filter(m,dd,qq(2000,1):qq(2015,4));
\end{verbatim}


